package cn.kgc.ssm.controller;

import cn.kgc.ssm.annotatios.LogOperation;
import cn.kgc.ssm.commons.ResponseResult;
import cn.kgc.ssm.entity.Active;
import cn.kgc.ssm.enums.OperationType;
import cn.kgc.ssm.service.ActiveService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

/**
 * @author 课工场
 * @date 2024/5/17
 * @description 活动管理
 */
@RestController
@RequestMapping("active")
public class ActiveController {


    @Resource
    private ActiveService activeService;


    // 根据id  获取活动信息
    @RequestMapping("getById")
    public ResponseResult getActiveById(Integer id) {
        return  activeService.getActiveById(id);
    }

    // 编辑活动信息
    @RequestMapping("edit")
    @LogOperation(model = "活动模块",operation = OperationType.UPDATE)
    public ResponseResult editActive(Active active) {
        return  activeService.editActive(active);
    }


    // 删除活动信息
    @RequestMapping("delete")
    @LogOperation(model = "活动模块",operation = OperationType.DELETE)
    public ResponseResult deleteActive(Integer[] ids) {
        return  activeService.deleteActive(ids);
    }


    // 发布活动
    @RequestMapping("add")
    @LogOperation(model = "活动模块",operation = OperationType.ADD)
    public ResponseResult addActive(String content, HttpSession session) {
        return  activeService.addActive(session,content);
    }


    //   活动信息分页查询
    @RequestMapping("page")
    public ResponseResult activePage(Integer page,Integer limit , String publisher) {

        return  activeService.activePage(page,limit,publisher);
    }

    // 前端活动信息的展示接口  前五条
    @RequestMapping("front/list")
    public ResponseResult activeList() {

        return  activeService.activeList();
    }

}
